<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 10/24/18
 * Time: 2:50 PM
 */

namespace console\members\wodrow\reverse_proxy;


class OuterNet
{
    public $outer_host = '0.0.0.0';
    public $outer_port = 9520;

    public function start()
    {
        $_s = new \swoole_server($this->outer_host, $this->outer_port);
        $_s->on('start', function (\swoole_server $server){
            var_dump($server->master_pid);
            var_dump($server->manager_pid);
        });
        $_s->on('connect', function (\swoole_server $server, $fd, $reactor_id){
            var_dump("connect: {$fd}");
        });
        $_s->on('receive', function (\swoole_server $server, $fd, $reactor_id, $data){
            var_dump("receive: {$fd}, data: {$data}");
            $server->send($fd, "receive to {$fd}: {$data}");
        });
        $_s->on('close', function (\swoole_server $server, $fd, $reactor_id){
            var_dump("close: {$fd}");
        });
        $_s->start();
    }
}